package com.snda.lib.util;

import com.snda.lib.util.ImageDownloader.Callback;

import android.content.Context;
import android.graphics.Bitmap;
import android.widget.ImageView;

/**
 * UI相关的辅助功能
 * 
 * @author Administrator
 * 
 */
public class UIHelper {

	/**
	 * 图片异步渲染 + 本地代理缓存
	 * 
	 * @param context
	 * @param imageView
	 * @param imageUrl
	 * @param callback
	 */
	public static Bitmap setImageView(Context context,
			final ImageView imageView, String strImageUrl, String strCacheDir) {

		// 左侧的ImageView
		Bitmap bitmap = ImageDownloader.loadImage(context, strImageUrl,
				strCacheDir, new Callback() {
					public void imageLoaded(Bitmap bitmap, String strImageUrl) {
						if (imageView != null && bitmap != null) {
							imageView.setImageBitmap(bitmap);
						}
					}
				});

		if (bitmap != null) {
			imageView.setImageBitmap(bitmap);
		}

		return null;
	}

}
